package com.xxx.controller;


import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.xxx.config.Request;
import com.xxx.pojo.Label;
import com.xxx.pojo.User;
import com.xxx.pojo.vo.UserVo;
import com.xxx.service.LabelService;
import com.xxx.service.UserService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author George
 * @since 2023-07-06
 */
@Api(tags = "标签控制")
@CrossOrigin
@RestController
@RequestMapping("/label")
public class LabelController {

    @Resource
    private LabelService labelService;

    /**
     * 添加标签
     *
     */
    @ApiOperation(value = "添加标签", notes = "注册添加新标签")
    @PostMapping("/addLabel")
    public Request addLabel(
            @RequestParam("labelCategory") String labelCategory){
        // 创建Client对象并设置属性

        Label label = new Label();
        label.setLabelCategory(labelCategory);
        boolean save = labelService.save(label);

        return save ? Request.suc() : Request.error("添加部门失败");
    }

    /**
     * 查询所有标签
     *
     * @return 返回用户列表和总数
     */
    @ApiOperation(value = "查询标签", notes = "查询所有标签")
    @GetMapping("/queryLabel")
    public Request getQueryLabel(){
        List<Label> list = labelService.list();
        return list.size() > 0 ? Request.suc(list) : Request.error("查询失败");
    }





}

